//创建对象
//使用对象字面量
var person = {
    firstname: "bill",
    lastname: "gates",
    age: 62,
    eyecolor: "blue"
};


//使用关键词new
var person1 = new Object();
person1.firstname = "bill";
person1.lastname = "gates";
person1.age = 40;
person1.eyecolor = "blue";

delete person1.eyecolor;


console.log(person.age)
console.log(person1.age)

var txt = "";
var x;
for (x in person1) {
    txt += person1[x] + "  ";
}
console.log(txt)


//对象方法
var person2 = {
    name: "mahu",
    age: 23,
    methodname: function () {
        console.log(this.name + " " + this.age + " years old");
    }

}

person2.methodname()

var message = "hello world";
console.log(message.toUpperCase())


function person3(firstname, lastname, age, eyecolor) {
    this.firstname = firstname;
    this.lastname = lastname;
    this.age = age;
    this.eyecolor = eyecolor;
    this.changename = function (name) {
        this.lastname = name;
    };
}
var myborther = new person3();
myborther.changename("jobs");
console.log(myborther.lastname)